﻿using FPSO.HMI.Controls;
using FPSO.Models.Domain;
using FPSO.Services.Utils;
using MySql.Data.MySqlClient;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Opc.Ua;
using SqlSugar;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FPSO.Services.Impl
{
	public class DBUserInfoService : DbRepository<UserInfo>
	{
		public void AddUserInfo(UserInfo log)
		{
			log.UserCreateTime = DateTime.Now;
			log.UserUpdateTime = DateTime.Now;
			InsertEntity(log);
		}

		public void DeleteUserInfo(int logid)
		{
			DeleteById(logid);
		}

		public UserInfo GetUserInfo(int logId)
		{
			UserInfo log = QueryEntity(t => t.UserId == logId);
			return log;
		}

		public UserInfo GetUserInfo(string username)
		{
			UserInfo log = QueryEntity(t => t.UserName == username);
			return log;
		}

		public void UpdateUserInfo(UserInfo log)
		{
			log.UserUpdateTime = DateTime.Now;
			UpdateEntity(log);
		}

		public List<UserInfo> GetAllUserInfos()
		{
			return QueryListByCondition("");
		}

		public int GetDataCount()
		{
			return QueryCount(t => t.UserUpdateTime >= DateTime.MinValue);
		}

		public void FlushDatas()
		{
			FlushEntitys();
		}
	}
}
